package com.food.eat.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import sun.misc.BASE64Decoder;

import java.io.IOException;

/**
 * @Author:RenPu
 * @Date: 2020/7/19 21:02
 * @Version: 1.0
 * @description:
 */

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    //swagger2访问路径：http://localhost:8001/swagger-ui.html 原路径
    // bootstrap生成的文档路径：http://localhost:8001/doc.html
    @Bean
    public Docket getDocket() {
        return new Docket(DocumentationType.SWAGGER_2)     //指定swagger的版本
                .apiInfo(getApiInfo())                      //用于定义api的一些文档展示信息的定义
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.food.eat.controller"))  //指定要使用swagger2创建文档的类路径
                .paths(PathSelectors.any())                //类路径下所有的controller类
                .build();                                   //进行创建
    }

    private ApiInfo getApiInfo() {

        return new ApiInfoBuilder()
                .title("天天吃货电商  api接口文档")            //文档页标题
                .description("转为天天吃货，提供的api文档")                             // 详细信息
                .contact(new Contact("云中天脊", "https://www.baidu.com", "abc.@qqcom"))
                .version("1.0.1")                            //版本号
                .termsOfServiceUrl("https://www.baidu.com")                        //网站地址
                .build();

    }


    public static void main(String[] args) throws IOException {
        byte[] bt = (new BASE64Decoder()).decodeBuffer("$db_3.9TYdms");
        String key=new String(bt);
        System.out.println(key);
    }


}
